#ifndef CONFIGDEVICEDLG_H
#define CONFIGDEVICEDLG_H

#include <QDialog>
#include "qknxserial.h"
#include "errortodo.h"

namespace Ui {
class ConfigDeviceDlg;
}

class ConfigDeviceDlg : public QDialog
{
    Q_OBJECT
    
public:
    explicit ConfigDeviceDlg(QWidget *parent = 0);
    ~ConfigDeviceDlg();
    
public slots:
    //通过物理地址搜索序列号
    void searchSNByPA();
    
    //搜索物理地址为0xFF的设备的序列号
    void searchSNWhenPAFF();
    
    //通过序列号搜索设备
    void searchDeviceBySN();

    //读取处于编程模式的设备的物理地址    
    void readPAWhenDeviceProMode();
    
    void downloadPA();
    
    void downloadData();

private slots:
    void updateSearchSNByPABtn(const QString &text);

    void updateSearchDeviceBySNBtn(const QString &text);

    void updateDownloadPAAndDataBtn(const QString &text);

    void selectSearchMethodOne(bool checked);

    void selectSearchMethodTwo(bool checked);

private:
    Ui::ConfigDeviceDlg *ui;
    
    QknxSerial *knxSerial;
    
    ErrorToDo *error;
    
    void downloadPABySN();
    
    void downloadPAWhenProMode();

    int judgeDeviceTypeAndMode();

    int sendInterfaceObjectTableData();

    int sendCOMMObjectTableData();

    int sendAddressTableData();

    int sendRelationTableData();
};

#endif // CONFIGDEVICEDLG_H
